package com.young.shop.pojo.vo;

public class BaseRespVOThree<T> {
    //状态：成功，失败
    private int code;
    //失败信息
    private String msg;
    //业务信息
    private T data;

    //枚举列举状态
    public enum CodeType {
        SUCCESS(100), FAILED(101);
        private int value;

        CodeType(int value) {

            this.value = value;
        }

        public int getValue() {

            return value;
        }
    }

    //成功返回标准
    public BaseRespVOThree success(T data) {
        BaseRespVOThree<Object> result = new BaseRespVOThree<>();
        result.setData(data);
        return result;
    }

    //失败返回标准
    public BaseRespVOThree failed(String msg) {
        BaseRespVOThree<Object> result = new BaseRespVOThree<>();
        result.setMsg(msg);
        return result;
    }

    @Override
    public String toString() {
        return "BaseRespVO{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
